<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>具名插槽的使用</title>
</head>
<body>
  <div id="app">
    <cpn>
      <!-- 已废弃的语法: -->
      <!-- <button slot="left">返回</button>
      <span slot="center"> 标题</span> -->

      <!-- 新语法:在template标签添加v-slot属性，参数为name -->
      <template v-slot:left>
        <button>返回</button>
      </template>
      <!-- v-slot的语法糖：v-slot:name -> #name -->
      <template #center>
        <span>标题</span>
      </template>
    </cpn>
  </div>

  <template id="cpn">
    <div>
      <!-- 有多个插槽时，给插槽一个name属性，以便在组件中可以决定替换哪个插槽 -->
      <slot name="left"><span>左边</span></slot>
      <slot name="center"><span>中间</span></slot>
      <slot name="right"><span>右边</span></slot>
    </div>
  </template>

  <script src="../js/vue.js"></script>
  <script>

    const app = new Vue({
      el: '#app',
      data: {
        message: '你好啊'
      },
      components: {
        cpn: {
          template: '#cpn',
        }
      }
    })
    
  </script>
</body>
</html>